package com.ai.controller.bt;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ai.common.controller.BaseController;
import com.ai.common.model.Result;
import com.ai.mmd.reviewed.dto.StatisticsDTO;
import com.ai.mmd.reviewed.vo.StatisticsVO;
import com.ai.service.reviewed.model.YhxxModel;
import com.ai.service.reviewed.service.ISbhzinfoService;

@RequestMapping("/front/Statistics")
@Controller("com.ai.controller.bt.StatisticsController")
public class StatisticsController extends BaseController{
	
	/**
	 * Description ：箱量统计引导页
	 */
	@RequestMapping("/xlstatisticsindex")
	public String xlstatisticsindex() {
		
		YhxxModel yhxxModel = (YhxxModel)request.getSession().getAttribute("yhxxModel");
		if (yhxxModel==null) {
			return "/front/frontgoods/login";
		}
		
		Result result = new Result(true);
        result.rendering();
		
		return "/front/frontgoods/btsb/statisticsxl";
	}
	
	/**
	 * Description ：运输类型箱量统计引导页
	 */
	@RequestMapping("/yslxxlstatisticsindex")
	public String yslxxlstatisticsindex() {
		
		YhxxModel yhxxModel = (YhxxModel)request.getSession().getAttribute("yhxxModel");
		if (yhxxModel==null) {
			return "/front/frontgoods/login";
		}
		
		Result result = new Result(true);
        result.rendering();
		
		return "/front/frontgoods/btsb/statisticsyslxxl";
	}
	
	/**
     * 统计箱量
     *
     * @param statisticsDTO
     * @return
     * @throws Exception
     */
    @ResponseBody
    @RequestMapping("xlStatistics")
    public Map<String, Object> xlStatistics(
            @ModelAttribute StatisticsDTO statisticsDTO) throws Exception {
        List<String> categories = new ArrayList<String>();
        categories.add("第一季度");
        categories.add("第二季度");
        categories.add("第三季度");
        categories.add("第四季度");
        Map<String, Object> resultMap = new HashMap<String, Object>();
        YhxxModel yhxxModel = (YhxxModel)request.getSession().getAttribute("yhxxModel");
        if (yhxxModel!=null) {
        	statisticsDTO.setYhid(yhxxModel.getYhid());
		}
        List<StatisticsVO> list = isbhzinfoService.getXlStatistics(statisticsDTO);
        resultMap.put("list", list);
        resultMap.put("categories", categories);
        return resultMap;
    }
	
	@Resource(name = "isbhzinfoService")
	private ISbhzinfoService isbhzinfoService;
}
